from selenium.webdriver.common.by import By


work_element = '//*[@id="resume-page"]/div/div/div[2]'
name_element = '//*[@id="recommend-list"]/div/ul/li[1]/div/div[1]/div[2]/div[1]/span[1]'
f = '工作经历'


def person_data(driver):
    """
    获取用户工作经历
    :return:
    """
    try:
        # 判断工作经历是否存在,不存在则跳过
        career_element = driver.find_element(By.XPATH, work_element)
        for career in career_element:
            if f not in career.text:
                continue
            else:
                career_data = career.text
                print("获取用户工作经历成功:", career_data)
                return career_data

    except Exception as e:
        print(f"获取用户工作经历时发生错误: {e}")
        raise e


def person_name(driver):
    """
    获取单个用户信息
    :return:
    """
    try:
        # 定位人员元素
        elements = driver.find_element(By.XPATH, name_element)
        elements.click()

    except Exception as e:
        print(f"获取单个用户信息时发生错误: {e}")
        raise e
